package com.gitee.mp.configure;

import cn.hutool.core.util.ClassUtil;
import cn.hutool.core.util.ObjectUtil;
import com.gitee.mp.infra.constants.MilvusPlusConstants;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author hongda.li
 */
@Getter
public class MilvusConfigure {
    /**
     * 需要扫描的包名称
     */
    private final List<String> locationList = new ArrayList<>();

    /**
     * 连接配置信息
     */
    private final List<MilvusConnection> connectionList = new ArrayList<>();

    public MilvusConfigure addConnection(MilvusConnection connection) {
        // 默认连接ID
        String connectorId = ObjectUtil.defaultIfNull(connection.getConnectorId(), MilvusPlusConstants.DEFAULT_ID);
        connection.setConnectorId(connectorId);
        this.connectionList.add(connection);
        return this;
    }

    public MilvusConfigure addLocation(String location) {
        this.locationList.add(location);
        return this;
    }

    public MilvusConfigure addLocation(Class<?> baseClass) {
        return this.addLocation(ClassUtil.getPackage(baseClass));
    }
}
